kindle ear

KindleEar is a github repo for generating and pushing subscription stuff to your kindle.

1 Installation

1.1 prepare

python2.7.x

1.2 Google accounts

  • Register here.
  • Enable less secure application here.
  • Apply a google project here.
https://console.developers.google.com/iam-admin/settings?project=YOUR_PROJECT_ID

1.3 GAE SDK1

1
2
3
4
5
wget -q https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-225.0.0-darwin-x86_64.tar.gz
tar -xzf google-cloud-sdk*
cd google-cloud-sdk*
./install.sh
./bin/gcloud init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
➜  google-cloud-sdk ./install.sh
Welcome to the Google Cloud SDK!

To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:

gcloud config set disable_usage_reporting true

Do you want to help improve the Google Cloud SDK (Y/n)?


Your current Cloud SDK version is: 225.0.0
The latest available version is: 225.0.0

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Components │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤
│ Status │ Name │ ID │ Size │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤
│ Not Installed │ App Engine Go Extensions │ app-engine-go │ 56.4 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 6.3 MiB │
│ Not Installed │ Cloud Bigtable Emulator │ bigtable │ 4.3 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool │ datalab │ < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator │ cloud-datastore-emulator │ 17.7 MiB │
│ Not Installed │ Cloud Datastore Emulator (Legacy) │ gcd-emulator │ 38.1 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator │ pubsub-emulator │ 33.4 MiB │
│ Not Installed │ Cloud SQL Proxy │ cloud_sql_proxy │ 3.7 MiB │
│ Not Installed │ Emulator Reverse Proxy │ emulator-reverse-proxy │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder │ cloud-build-local │ 5.9 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr │ 1.8 MiB │
│ Not Installed │ gcloud Alpha Commands │ alpha │ < 1 MiB │
│ Not Installed │ gcloud Beta Commands │ beta │ < 1 MiB │
│ Not Installed │ gcloud app Java Extensions │ app-engine-java │ 108.8 MiB │
│ Not Installed │ gcloud app PHP Extensions │ app-engine-php │ 21.9 MiB │
│ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 6.2 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries) │ app-engine-python-extras │ 28.5 MiB │
│ Not Installed │ kubectl │ kubectl │ < 1 MiB │
│ Installed │ BigQuery Command Line Tool │ bq │ < 1 MiB │
│ Installed │ Cloud SDK Core Libraries │ core │ 8.9 MiB │
│ Installed │ Cloud Storage Command Line Tool │ gsutil │ 3.5 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴───────────┘
To install or remove components at your current SDK version [225.0.0], run:
$ gcloud components install COMPONENT_ID
$ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [225.0.0], run:
$ gcloud components update


Modify profile to update your $PATH and enable shell command
completion?

Do you want to continue (Y/n)?

The Google Cloud SDK installer will now prompt you to update an rc
file to bring the Google Cloud CLIs into your environment.

Enter a path to an rc file to update, or leave blank to use
[/Users/eula/.zshrc]:
Backing up [/Users/eula/.zshrc] to [/Users/eula/.zshrc.backup].
[/Users/eula/.zshrc] has been updated.

==> Start a new shell for the changes to take effect.


For more information on how to get started, please visit:
https://cloud.google.com/sdk/docs/quickstarts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
➜  google-cloud-sdk ./bin/gcloud init
Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)?

Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.ap
ps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%
2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&acc
ess_type=offline


You are logged in as: [your_gmail_account@gmail.com].

Pick cloud project to use:
[1] your_project_id-01
[2] your_project_id-02
[3] your_project_id-03
[4] your_project_id-04
[5] your_project_id-05
[6] your_project_id-06
[7] your_project_id-07
[8] your_project_id-08
[9] your_project_id-09
[10] your_project_id-10
[11] your_project_id-11
[12] your_project_id-12
[13] Create a new project
Please enter numeric choice or text value (must exactly match list
item): 1

Your current project has been set to: [your_project_id-01].

Not setting default zone/region (this feature makes it easier to use
[gcloud compute] by setting an appropriate default value for the
--zone and --region flag).
See https://cloud.google.com/compute/docs/gcloud-compute section on how to set
default compute region and zone manually. If you would like [gcloud init] to be
able to do this for you the next time you run it, make sure the
Compute Engine API is enabled for your project on the
https://console.developers.google.com/apis page.

Created a default .boto configuration file at [/Users/eula/.boto]. See this file and
[https://cloud.google.com/storage/docs/gsutil/commands/config] for more
information about configuring Google Cloud Storage.
Your Google Cloud SDK is configured and ready to use!

Commands that require authentication will use your_gmail_account@gmail.com by default
Commands will reference project `your_project_id-01` by default

1.4 KindleEar download and configuration

1
2
wget -qO KindleEar.zip https://github.com/cdhigh/KindleEar/archive/master.zip
unzip KindleEar.zip

Modify 3 files under KindleEar with your google application id, gmail, domain name.

File Item Note
app.yaml application Project ID
module_worker.yaml application Project ID
config.py DOMAIN http://project_id.appspot.com
config.py SRC_EMAIL gmail

1.5 Deploying KindleEar to GAE

1
2
3
### Go to your google-cloud-sdk
cd google-cloud-sdk
./gcloud app deploy --project Project_ID ~/Downloads/KindleEar-master/app.yaml ~/Downloads/KindleEar-master/module-worker.yaml
WARNING: In file [/Users/xxxx/Downloads/KindleEar-master/module-worker.yaml]: ('module', 'Field module is deprecated; use service instead.')
Initializing App Engine resources...done.
Services to deploy:

descriptor:      [/Users/xxxx/Downloads/KindleEar-master/app.yaml]
source:          [/Users/xxxx/Downloads/KindleEar-master]
target project:  [YOUR_project_ID]
target service:  [default]
target version:  [20181121t131444]
target url:      [https://YOUR_project_ID.appspot.com]


descriptor:      [/Users/xxxx/Downloads/KindleEar-master/module-worker.yaml]
source:          [/Users/xxxx/Downloads/KindleEar-master]
target project:  [YOUR_project_ID]
target service:  [worker]
target version:  [20181121t131444]
target url:      [https://worker-dot-YOUR_PROJECT_ID.appspot.com]


Do you want to continue (Y/n)?

Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 489 files to Google Cloud Storage              ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://YOUR_project_ID.appspot.com]
Beginning deployment of service [worker]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 0 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.

1.6 Install the kindleear on Google Cloud shell.

Start cloud shell guide

Select or Create a App here , then Click the Activate Cloud Shell button, and Start shell button.

https://console.cloud.google.com/home/dashboard

Run these command in shell if you work on an old project

1
2
gcloud config set project your_project_id
rm -f uploader.sh* && wget https://raw.githubusercontent.com/kindlefere/KindleEar-Uploader/master/uploader.sh && chmod +x uploader.sh && ./uploader.sh

Run these commands in shell if you create a new project

1
2
gcloud beta app create
rm -f uploader.sh* && wget https://raw.githubusercontent.com/kindlefere/KindleEar-Uploader/master/uploader.sh && chmod +x uploader.sh && ./uploader.sh

Wait kindleear to finish installation

Google project id and gmail should be entered during installation.

https://console.cloud.google.com/appengine/settings?project=YOUR_PROJECT_ID goto this webpage to set Google Accounts API.

The vist https://your_project_id.appspot.com and setting with default admin(password admin).

Add your gmail to Email sender

If you don't add this, you will get error wrong SRC_EMAIL when diliver the subscription.

  • On left dashboard's App Engine – settings – email sender.
  • If your gmail is not in this list, click ADD on the right of Settings, then enter your gmail with a TAB to finish your input.
  • Finally click ADD. Done!

2 Configuration

Now, read the FAQ to get it works as you wish.

3 Post configuration

  1. Goto amazon - your content and device - preferences - Personal Document Settings
  2. Add the gmail to approved email list
  3. Disable less secure application here.

4 Issues

4.1 gcloud deploy error

1
2
3
4
➜  bin ./gcloud app deploy --version=1 /Users/xxx/Downloads/KindleEar-master/app.yaml /Users/xxx/Downloads/KindleEar-master/module-worker.yaml
ERROR: (gcloud.app.deploy) The [application] field is specified in file [/Users/xxx/Downloads/KindleEar-master/app.yaml]. This field is not used by gcloud a
nd must be removed. Project name should instead be specified either by `gcloud config set project MY_PROJECT` or by setting the `--project` flag on individua
l command executions.

Change the google cloud app deploy tool according to current version and notes.

4.2 DONE internal server error

Click to GAE dashboard, Datastore – indexes, check Book, DeliverLog, Feed status. Maybe should update indexes.

1
appcfg.py update_indexes ./

When encountered this error, I decided to reinstall the kindleear in google cloud shell.